package org.common.utils.net.netty.http.core;

import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpServerCodec;
import org.common.utils.net.netty.core.NettyHandler;
import org.common.utils.net.netty.core.NettyInitializer;

/**
 * 默认的http初始化器
 * @author zhouzhibing
 * @date 2025/11/14 22:29
 */
public class HttpInitializer extends NettyInitializer {

    /**
     * 构造函数
     * @param handler 处理器
     */
    public HttpInitializer(NettyHandler handler) {
        super("nettyHttp", null, null, handler);
    }

    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ChannelPipeline pipeline = ch.pipeline();
        pipeline.addLast(new HttpServerCodec());
        pipeline.addLast(new HttpObjectAggregator(65536));
        pipeline.addLast(handler);
    }
}
